/**
 * form layout component
 * @author werts
 */
import { Component, OnInit, OnChanges } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';

import { FormsElementsBase } from './class.forms.elements.base';
import { Forms } from './class.forms';
import { FormsService } from './service.forms';
import { FormControlBuildService } from './service.forms.control.build';

import { School } from './class.school';

@Component({
    selector: 'wf-form-layout',
    templateUrl: './template.form.layout.html',
    providers: [
        FormsService,
        FormControlBuildService
    ]
})

export class FormLayoutComponent implements OnInit, OnChanges {
    formElements: Forms;
    wfFormGroup: FormGroup;
    blockCol: number = 4;
    userName: FormControl = new FormControl('');
    inputType: string = "password"
    selOption: Array<object> = [new School(12, 'hafo'), new School(13,'balala')];
    selectOp: Array<object> = [new School(1, 'aaaaa'), new School(2,'asdasd')];
    textareaLa:string = "textareaLabel"
    wfrows: number = 4;
    wfcols: number = 60;
    classes: string = "btn btn-info";
    disabled:boolean = true;
    btnname: string = "这是一个按钮";
    btnicon: string = "glyphicon glyphicon-search m-r-sm";
    btnVertical: string= "btnVertical";


    constructor(
        private formService: FormsService,
        private formControlBuildService: FormControlBuildService
    ) { }

    get userLabel(): string {
        return 'hehe label';
    }

    get selLabel(): string {
        return 'select label';
    }

    get pla(): string {
        return '输入框输入框输入框输入框'
    }

    get checkLabel(): string {
     return 'Check me out'
   }

   get checkOptions(): string {
     return 'option'
   }

   get radioLabel(): string {
       return 'radio'
   }

    ngOnChanges() {
    }

    ngOnInit() {
        this.formService.getFormAndFormElements().subscribe(formElements => {
            this.formElements = formElements;
            console.log(this.formElements);
        }, error => {
            console.log(`获取表单元素报错${error}`);
        });
        this.wfFormGroup = this.formControlBuildService.buildFormCtrol();
    }

    /**
     * 表单提交处理方法
     */
    onSubmit() {

    }
}
